<?php 

class perfilActions extends sfActions
{

	public function executeIndex(sfWebRequest $request)
	{
		$this->user = $this->getUser()->getGuardUser();
	}

	public function executeChangePassword(sfWebRequest $request)
	{
		$this->form = new ChangePasswordForm();

		if ($request->isMethod('post'))
		{
			$this->form->bind($request->getParameter($this->form->getName()));

			if ($this->form->isValid())
			{
				if ($this->getUser()->setPassword(/*$this->form->getValue('current_password'), */$this->form->getValue('new_password')))
				{
					$this->getUser()->setFlash('notice', 'La contraseña ha sido actualizada');
					$this->redirect('@profile');
				}
			}

			$this->getUser()->setFlash('error', 'La contraseña no se ha cambiado porque se ha producido un error', false);
		}
	}

}